package user_api

import (
	"github.com/gogf/gf/frame/g"
)

// 分组模块
const (
	OPEN_API_GROUP_NAME_LIST                    = "user.group.list"
	OPEN_API_GROUP_NAME_CREATE                  = "user.group.create"
	OPEN_API_GROUP_NAME_UPDATE                  = "user.group.update"
	OPEN_API_GROUP_NAME_DELETE                  = "user.group.delete"
	OPEN_API_GROUP_NAME_METHODS                 = "user.group.methods"
	OPEN_API_GROUP_NAME_METHODS_SAVE            = "user.group.methods.save"
	OPEN_API_GROUP_SYSTEM_GET                   = "system.accesses.get"
)

// 获取方法列表
func GetGroupList(params map[string]interface{}) string {
	return CallApi(OPEN_API_GROUP_NAME_LIST, params)
}

// 创建方法
func CreateGroup(params map[string]interface{}) string {
	return CallApi(OPEN_API_GROUP_NAME_CREATE, g.Map{
		"name":   params["name"],
	})
}

// 编辑方法
func UpdateGroup(id string, params map[string]interface{}) string {
	return CallApi(OPEN_API_GROUP_NAME_UPDATE, g.Map{
		"api_uri_placeholder_values": g.Map{
			"id": id,
		},
		"name":   params["name"],
	})
}

// 删除方法
func DeleteGroup(id string) string {
	return CallApi(OPEN_API_GROUP_NAME_DELETE, g.Map{
		"api_uri_placeholder_values": g.Map{
			"id": id,
		},
	})
}

// 获取分组权限
func GetGroupAccesses(id string, perLine int) string {
	return CallApi(OPEN_API_GROUP_NAME_METHODS, g.Map{
		"api_uri_placeholder_values": g.Map{
			"id": id,
		},
		"perLine": perLine,
	})
}


// 获取分组权限
func SaveGroupAccesses(id string, methodIds []string) string {
	return CallApi(OPEN_API_GROUP_NAME_METHODS_SAVE, g.Map{
		"api_uri_placeholder_values": g.Map{
			"id": id,
		},
		"methodIds": methodIds,
	})
}
